<template>
  <div id="app" :class="{ active: $route.meta.appfalg }">
    <!-- tabbar -->
    <div class="routerliks" v-if="$route.meta.appfalg">
      <router-link to="/" key="/">
        <span class="listimg"><img src="./assets/image/ic_tab_library.png" v-if="home" />
          <img src="./assets/image/ic_tab_library_select.png" v-else />
        </span>
        <span :class="{ active: !home }">首页</span>
      </router-link>
      <router-link to="/gongtoeat" key="/go"><span class="listimg">
          <img src="./assets/image/ic_tab_homepage.png" v-if="gotoeat" />
          <img src="./assets/image/ic_tab_homepage_select.png" v-else />
        </span>
        <span :class="{ active: !gotoeat }">逛吃</span>
      </router-link>

      <router-link to="/about"><span class="listimg"><img src="./assets/image/ic_tab_my.png" v-if="mede" />
          <img src="./assets/image/ic_tab_my_select.png" v-else /></span>
        <span :class="{ active: !mede }">我的</span>
      </router-link>
    </div>
    <!-- /tabbar -->
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>

  </div>
</template>

<script>
// import HelloWorld from "@/components/HelloWorld.vue";
export default {
  name: "app",
  components: {
    // HelloWorld,
  },
  data() {
    return {
      home: true,
      gotoeat: true,
      mede: true,
      isshow: false,
    };
  },
  watch: {
    $route(n) {
      this.isshow = n.meta.keepAlive
      this.home = true;
      this.gotoeat = true;
      this.mede = true;
      if (n.name === "Home") {
        this.home = false;
      }
      if (n.name === "GongToEat") {
        this.gotoeat = false;
      }
      if (n.name === "About") {
        this.mede = false;
      }
    },
  },
  created() {
    this.home = false;
    // console.log(this.$router);
  },
};
</script>

<style lang="less" scoped>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;

  &.active {
    padding-bottom: 9vh;
  }

  .routerliks {
    border-top: 1px solid rgba(128, 128, 128, 0.24);
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 8vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    z-index: 1;

    a {
      display: flex;
      flex-direction: column;
      align-items: center;
      font-size: 15px;
      color: gray;

      &:nth-child(2) {
        margin: 0 30px;
      }

      &.router-link-exact-active {
        color: orange;
      }

      .listimg {
        display: block;
        width: 30%;

        img {
          width: 100%;
        }
      }
    }
  }
}
</style>
